package net.lulihu.pangolin.headless.client.handler;

import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import net.lulihu.pangolin.headless.client.kit.CmdChannelKit;
import net.lulihu.pangolin.headless.common.protocol.handler.MessageHandler;

/**
 * 代理消息处理程序
 */
@Slf4j
public class ProxyClientMessageHandler extends MessageHandler {

    @Override
    public void channelInactive(ChannelHandlerContext ctx) {
        // 检查是否为cmd 通道 如果是尝试重新建立连接
        CmdChannelKit.checkIfCmdChannel(ctx.channel());
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        ctx.channel().close();
        log.error("", cause);
    }

}
